
cd "" // set working directory here

use "incumbency shooting data.dta", clear

areg incumbent_party_held num_shootings_std  i.year, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend, model_num, 1, party, Pooled) replace 
areg incumbent_party_held num_shootings_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend, model_num, 2, party, Pooled) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend deaths, model_num, 3, party, Pooled) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend deaths, model_num, 4, party, Pooled) append 

	areg dv num_shootings_std  i.year, absorb(state_district_num) cluster(state_district_num)
	areg dv num_shootings_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
	areg dv deaths_plus_injuries_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
	areg dv had_shooting  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)

	areg dv_std num_shootings_std  i.year, absorb(state_district_num) cluster(state_district_num)
	areg dv_std num_shootings_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
	areg dv_std deaths_plus_injuries_std  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)
	areg dv_std had_shooting  i.year i.state_district_num#c.year, absorb(state_district_num) cluster(state_district_num)

*By Party--Democrats
areg incumbent_party_held num_shootings_std  i.year if inc==1, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend, model_num, 1, party, Democrats) append 
areg incumbent_party_held num_shootings_std  i.year i.state_district_num#c.year  if inc==1, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend, model_num, 2, party, Democrats) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year if inc==1, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend deaths, model_num, 3, party, Democrats) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year i.state_district_num#c.year if inc==1, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend deaths, model_num, 4, party, Democrats) append 

*By Party--Republicans
areg incumbent_party_held num_shootings_std  i.year if inc==0, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend, model_num, 1, party, Republicans) append 
areg incumbent_party_held num_shootings_std  i.year i.state_district_num#c.year  if inc==0, absorb(state_district_num) cluster(state_district_num)
regsave num_shootings_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend, model_num, 2, party, Republicans) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year if inc==0, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, no trend deaths, model_num, 3, party, Republicans) append 
areg incumbent_party_held deaths_plus_injuries_std  i.year i.state_district_num#c.year if inc==0, absorb(state_district_num) cluster(state_district_num)
regsave deaths_plus_injuries_std using "incumbency_effects.dta", detail(all) addlabel(outcome, Incumbent Reelection, specification, trend deaths, model_num, 4, party, Republicans) append 


use "incumbency_effects.dta", clear
replace party=" Pooled" if party=="Pooled"
saveold "incumbency_effects.dta", version(12) replace
